package com.mengrv.springbootdemo.model;

import com.alibaba.fastjson.JSONObject;
import com.mengrv.springbootdemo.tool.MD5Tool;
import io.swagger.annotations.ApiModel;

@ApiModel(description = "用户")
public class User {
    private int id;
    private Long createdTime = System.currentTimeMillis();
    private Long birthday;
    private String userID;
    private String account;
    private String userName;
    private String mobile;
    private String password;
    private String positionName;
    private String token;
    private String positionCode;

    public void setPositionCode(String positionCode) {
        this.positionCode = positionCode;
    }

    public String getPositionCode() {
        return positionCode;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public void setBirthday(Long birthday) {
        this.birthday = birthday;
    }

    public void setCreatedTime(Long createdTime) {
        this.createdTime = createdTime;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public void newToken() throws Exception {
        JSONObject userInfo = new JSONObject();
        userInfo.put("creatTime", System.currentTimeMillis());
        userInfo.put("account", this.account);
        userInfo.put("password", this.password);
        this.token = MD5Tool.getMd5String(userInfo.toJSONString());
    }

    public void setToken(String token) {
        this.token = token;
    }

    public void updateID() throws Exception {
        JSONObject userInfo = new JSONObject();
        userInfo.put("creatTime", System.currentTimeMillis());
        userInfo.put("account", this.account);
        userInfo.put("userName", this.userName);
        this.userID = MD5Tool.getMd5String(userInfo.toJSONString());
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getUserID() {
        return userID;
    }

    public String getUserName() {
        return userName;
    }

    public String getPassword() {
        return password;
    }

    public int getId() {
        return id;
    }

    public Long getBirthday() {
        return birthday;
    }

    public Long getCreatedTime() {
        return createdTime;
    }

    public String getAccount() {
        return account;
    }

    public String getMobile() {
        return mobile;
    }

    public String getPositionName() {
        return positionName;
    }

    public String getToken() {
        return token;
    }
}
